﻿-- Author      : Kurapica
-- Create Date : 6/13/2008 5:22:03 PM
     
-- LayeredRegion
do
	-- Check Version
	local version = 1
	if not IGAS:RegisterFile("IGAS.GUI.Widget.LayeredRegion", version) then
		return
	end

    local getmetatable = getmetatable
    local pairs = pairs
    local ipairs = ipairs
    local type = type
    local error = error
    local CreateFrame = CreateFrame
    
	local _WidgetName = "LayeredRegion"
    local _Base = "Region"

	local _GUI = IGAS.GUI
	local _Widget = IGAS.GUI.Widget
    local _BaseFunc = IGAS.GUI.Base.Func
	local _PropertyType = IGAS.GUI.Base.PropertyType
	
    -- FuncProxy
	local _FuncProxy = {
        --- Original Functions
        -- GetDrawLayer() - Returns the draw layer for the Region - New in 1.10. 
        ["GetDrawLayer"] = function(self)
            return self.__UI:GetDrawLayer()
        end,
        
        -- SetDrawLayer("layer") - Sets the draw layer for the Region - New in 1.10.
        ["SetDrawLayer"] = function(self, layer)
            self.__UI:SetDrawLayer(layer)
        end,
        
        -- SetVertexColor(r, g, b[, alpha]) 
        ["SetVertexColor"] = function(self, r,g,b,a)
            self.__UI:SetVertexColor(r,g,b,a)
        end,
    }
    
	-- Property
	local _Property = {
		["DrawLayer"] = {		
			["Set"] = function(self, layer)
				self:SetDrawLayer(layer)
			end,
			
			["Get"] = function(self)
				return self:GetDrawLayer()
			end,
			
			["Type"] = _PropertyType.Layer,
		},
		
		["VertexColor"] = {
			["Set"] = function(self, color)
				self:SetVertexColor(color.red, color,green, color.blue, color.alpha)
			end,

			["Type"] = _PropertyType.Color,		
		},	
	}
	
    local _WidgetInfo = {
        ["WidgetName"] = _WidgetName,
        ["Base"] = _Base,
        ["FuncProxy"] = _FuncProxy,
        ["Property"] = _Property,
    }
    
    _Widget[_WidgetName] = _GUI.NewWidget(_WidgetInfo)
end														    